package gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

@SuppressWarnings("serial")
class NormalFrame extends Frame {
	
	NormalFrame(int width, int height) {
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int screenW = (int) screenSize.getWidth();
		int screenH = (int) screenSize.getHeight();
		this.setSize(width, height);
		this.setResizable(false);
		this.setLocation(screenW / 2 - this.getWidth() / 2, screenH / 2 - this.getHeight() / 2);
		this.setBackground(Color.BLACK);
		this.setLayout(null);
//		this.setUndecorated(true); //取消标题
		this.setVisible(true);
		
		this.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				if(e.getKeyCode() == KeyEvent.VK_ESCAPE) {
					setVisible(false);
				}
			}
		});
		
		this.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				setVisible(false);
			}
		});
	}
}
